package com.sweets.look.ui.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.webkit.WebView;

import java.util.HashMap;

public class FastView extends WebView {
    private boolean doNotTrackFlag;
    private boolean removeIdentifyingHeadersFlag;
    private int webColor;

    public FastView(Context context) {
        super(context);
        this.doNotTrackFlag = false;
        this.removeIdentifyingHeadersFlag = false;
        this.webColor = -1;
    }


    public FastView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        this.doNotTrackFlag = false;
        this.removeIdentifyingHeadersFlag = false;
        this.webColor = -1;
    }

    public int getWebColor() {
        return this.webColor;
    }

    public void loadUrl(String url) {
        HashMap<String, String> map = new HashMap<String, String>();
        if (this.doNotTrackFlag) {
            map.put("dnt", "1");
        }

        if (this.removeIdentifyingHeadersFlag) {
            map.put("x-requested-with", "");
            map.put("x-wap-profile", "");
        }

        super.loadUrl(url, map);
    }

    public void setDoNotTrack(boolean enable) {
        this.doNotTrackFlag = enable;
    }

    public void setRemoveIdentifyingHeaders(boolean enable) {
        this.removeIdentifyingHeadersFlag = enable;
    }

    public void setWebColor(int color) {
        this.webColor = color;
    }
}

